<?php
    include_once '../connection/databaseHandler.php';
    include_once '../connection/sessionHandler.php';
    $database = new DatabaseHandler();
    $session = new SessionHandler();

    //Mendapatkan semua informasi yang telah divalidasi di client-side
    $id_photo = $_POST['photo-id'];
    $title = $_POST['title'];
    $description = $_POST['description_content'];
    $keyword_id = $_POST['keyword'];
    $takendate = $_POST['date'];
    $photo_role = $_POST['photo_role'];
    $comment_role = $_POST['hak_comment'];
    $username = $session->username;

    $query = "UPDATE  $database->t_foto
                SET
                    title='$title',
                    id_keyword='$keyword_id',
                    description='$description',
                    date_taken='$takendate',
                    id_role='$photo_role',
                    id_hak_komentar='$comment_role'
                WHERE
                    id='$id_photo' ";
    if ($database->execQuery($query)) {
        header("location:../profile.php?page=photo-detail&photo-id=".$id_photo."&id=".$username);
    }
    else {
        //header("location:../profile.php?page=photo-detail&photo-id=".$id."&id=".$username);
    }


?>
